package com.yunhuakeji.wddx.utils;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class ResultUtil
{
	public InputStream resultString(String callback, Object result)
	{
		try
		{
			if (IsNull.isNotNull(callback))
				return new ByteArrayInputStream((callback + "(" + result + ")").toString().getBytes("utf-8"));
			return new ByteArrayInputStream(result.toString().getBytes("utf-8"));
		} catch (Exception e)
		{
			return new ByteArrayInputStream("error".getBytes());
		}
	}
	
	public InputStream resultString(Object result)
	{
		try
		{
			return new ByteArrayInputStream(result.toString().getBytes("utf-8"));
		} catch (Exception e)
		{
			return new ByteArrayInputStream("error".getBytes());
		}
	}
}
